package com.buding.fx.view;

import com.buding.fx.common.enums.PosEnum;
import com.buding.fx.utils.CaiPiaoCreateThread;
import com.buding.fx.utils.NotifyThread;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventTarget;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

/**
 * @author mingdongwei-jwk
 * @date 2023/07/07 15:38
 * @class com.buding.fx.view
 * @Description
 */
public class CaiPiaoMain extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        BorderPane borderPane = new BorderPane();
        borderPane.setPrefWidth(700);
        borderPane.setPrefHeight(500);

        FlowPane flowPane = new FlowPane();
        flowPane.setPrefWidth(borderPane.getPrefWidth());
        flowPane.setPrefHeight(35);
        flowPane.setAlignment(Pos.CENTER_LEFT);

        Label label = new Label("复试选号");
        Border border = new Border(new BorderStroke(Color.web("#c2bfbf"), BorderStrokeStyle.SOLID, new CornerRadii(0), new BorderWidths(0,1,1,0)));
        label.setBorder(border);
        label.setPrefWidth(80);
        label.setPrefHeight(35);
        label.getStyleClass().setAll("lab");
        label.setAlignment(Pos.CENTER);
        label.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                //异步更新左边组件
                Platform.runLater(new CaiPiaoCreateThread(borderPane,label));

            }
        });


        Label label1 = new Label("单式选号");
        label1.setBorder(border);
        label1.setPrefWidth(80);
        label1.setPrefHeight(35);
        label1.getStyleClass().setAll("lab");
        label1.setAlignment(Pos.CENTER);
        label1.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                //异步更新左边组件
                Platform.runLater(new CaiPiaoCreateThread(borderPane,label1));
            }
        });
        //默认单选
        label1.fireEvent(new MouseEvent(MouseEvent.MOUSE_CLICKED,1, 1, 1, 1, MouseButton.PRIMARY, 1, true, true, true, true, true,
                true, true, true, true, true, null));

        Label label2 = new Label("胆拖选号");
        label2.setBorder(border);
        label2.setPrefWidth(80);
        label2.setPrefHeight(35);
        label2.getStyleClass().setAll("lab");
        label2.setAlignment(Pos.CENTER);
        label2.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                Platform.runLater(new CaiPiaoCreateThread(borderPane,label2));
            }
        });
        Label label3 = new Label("定胆杀号");
        label3.setBorder(border);
        label3.setPrefWidth(80);
        label3.setPrefHeight(35);
        label3.getStyleClass().setAll("lab");
        label3.setAlignment(Pos.CENTER);
        label3.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                //异步更新左边组件
                Platform.runLater(new CaiPiaoCreateThread(borderPane,label3));

            }
        });
        flowPane.getChildren().addAll(label1,label,label2,label3);


        borderPane.setTop(flowPane);
        Scene scene = new Scene(borderPane);

        primaryStage.setScene(scene);
        primaryStage.setTitle("超级选号助手v1.0.01");
        primaryStage.centerOnScreen();
        primaryStage.setResizable(false);
        String css2 = "css/buding-fx-css-main.css";
        scene.getStylesheets().add(css2);

        primaryStage.show();
    }
}
